import React, {Component} from 'react';


class App extends Component {
    state = {
        isShow:false
    }

    render() {
        return (
            <div>
                <button onClick={()=>{
                    this.setState({
                        isShow:!this.state.isShow
                    })
                }}>click</button>
                {
                    this.state.isShow&&<Child/>
                }

            </div>
        );
    }
}

class Child extends Component{
    render() {
        return (
            <div>
                Child
            </div>
        )
    }
    componentDidMount() {
        window.onresize=()=>{
            console.log('onresize')
        }
    }


    //销毁
    componentWillUnmount () {
        console.log('componentWillUnmount')
        window.onresize=null
    }
}

export default App;